<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    function randCode(len) {
        // 参数的默认值   len 默认4
        // len = len == undefined ? 4 : len;  // 三目运算符
        len = len || 4;  // len有值 就只用len 否则len = 4
        var randList = numList.concat(bigList, smallList);
        var str = "";
        for (var i = 0; i < len; i++) {
            var index = Math.floor(Math.random()*randList.length);
            var char = randList[index];
            if(str.indexOf(char)==-1){
                str += char;
            }else{
                i--;
            }
        }
        return str;
    }

</script>
</html>